<template>
    <div class="ssss">
        <van-image round
            src="https://img01.yzcdn.cn/vant/cat.jpeg"
            />
            <p>{{user.name}}</p>
        <button @click="handleClick">{{num}}开启旅程</button>
    </div>
</template>

<script>
import {getCollectMovie} from '../model/MovieCollect'
    export default {
        data(){
            return{
                num:3,
                user:""
            }
        },
        async mounted() {
            var userurl = '/api/user'
            getCollectMovie(userurl).then(res=>{
                this.user = res.data.res
            })
        },
        created(){
            this.countreduce()
        },
        methods:{
            countreduce(){
                var num = this.num;
                this.timer = setTimeout(() => {
                    num--;
                    if(num>0){
                    this.num = num
                    }
                    if(num==0){
                        this.$router.push('/article')
                    }
                    this.countreduce()
                }, 1000);
            },
            handleClick(){
                clearInterval(this.timer);
                this.$router.push("/article")
            },
        }
    }
</script>

<style scoped>
.ssss{
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    background: rgb(44, 152, 185);
}
.van-image__img{
    width: 20px;
    height: 20px;
}
p{
    margin: 20px auto;
}
div{
text-align: center;
    font-size: 30px;
}
</style>